package com.example.flshtarvel.mapper;

import com.example.flshtarvel.entity.Tag;
import com.example.flshtarvel.entity.TagArticleMap;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TagArticleMapMapper {
    @Insert("insert into tag_article_map(tag_id,article_id) values(#{tagId},#{articleId})")
    public int insertTagArticleMap(String tagId, String articleId);

    //通过文章id删除
    @Delete("delete from tag_article_map where tag_article_map.article_id=#{articleId}")
    public int deleteTagArticleMapByArticleId(String articleId);

    //通过文章id搜索
    @Select("select * from tag,tag_type,tag_article_map where tag.tag_type_id=tag_type.tag_type_id and tag.tag_id=tag_article_map.tag_id and tag_article_map.article_id=#{articleId}")
    public List<Tag> selectTagByArticleId(String articleId);

    //通过标签id删除
    @Delete("delete from tag_article_map where tag_id=#{tagId}")
    public int deletetagArticleMapByTagId(String tagId);

    //通过标签id搜索
    @Select("select * from tag_article_map where  tag_id=#{tagId}")
    public List<TagArticleMap> selectArticleByTagId(String tagId);
}
